package com.shinemo.mpush.alloc.service.chat;

import com.mpush.api.chat.ChatMessageSendResult;
import com.mpush.netty.http.HttpClient;
import com.mpush.netty.http.NettyHttpClientUtils;
import com.mpush.tools.common.DateUtils;
import com.mpush.tools.config.CC;
import com.shinemo.mpush.alloc.http.DefaultHttpCallback;
import com.shinemo.mpush.alloc.http.MessageHttpCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class IosPushService {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    private HttpClient httpClient;

    public IosPushService(HttpClient httpClient){
        this.httpClient=httpClient;
    }

    public void push(Long sessionId,String userId,String message){
        String uri = "http://" + CC.mp.api.server_address + CC.mp.api.iosPush;
        Map<String, String> param = new HashMap<>(8);
        param.put("sessionId",""+sessionId);
        param.put("userId", userId);
        param.put("message",message);
        try {
            NettyHttpClientUtils.post(httpClient, uri, param, new DefaultHttpCallback(uri));
        } catch (Exception e) {
            logger.error("",e);
        }
    }
}
